/*
 * xstdlib.cpp
 *
 *  Created on: 14 sept. 2011
 *      Author: lindenb
 */
#include <cerrno>
#include <cstring>
#include "xstdlib.h"
#include "throw.h"

using namespace std;

void * safeCalloc (std::size_t nmemb, std::size_t size)
		{
		void* p=::calloc(nmemb,size);
		if(p==NULL) THROW("Cannot calloc "<<nmemb<<","<< size);
		return p;
		}

void * safeMalloc (std::size_t size)
		{
		void* p=::malloc(size);
		if(p==NULL) THROW("Cannot malloc "<<size);
		return p;
		}

void * safeRealloc (void * ptr, std::size_t size)
		{
		void* p=::realloc(ptr,size);
		if(p==NULL) THROW("Cannot realloc "<< size);
		return p;
		}
